home *** CD-ROM | disk | FTP | other *** search
/ Internet Info 1994 March / Internet Info CD-ROM (Walnut Creek) (March 1994).iso / networking / mail / mime / mime.txt < prev    next >
Text File  |  1993-02-04  |  35KB  |  832 lines

  1.  
  2.  
  3.                             MIME Overview
  4.  
  5.                 by Mark Grand <mark@premenos.sf.ca.us>
  6.  
  7. Internet e-mail allows mail messages to be exchanged between users of
  8. computers around the world and occasionally beyond... to space
  9. shuttles.  One of the main reasons that Internet e-mail has achieved
  10. such wide use is because it provides a standard mechanism for messages
  11. to be exchanged between over 1,000,000 computers connected to the
  12. Internet.
  13.  
  14. The standards that are the basis for Internet e-mail were established
  15. in 1982.  Though they were state of the art in 1982, in the
  16. intervening years they have begun to show their age.  The 1982
  17. standards allow for mail messages that contain a single human readable
  18. message with the restrictions that:
  19.  
  20.     * the message contains only ASCII characters.
  21.  
  22.     * the message contains no lines longer than 1000 characters.
  23.  
  24.     * the message does not exceed a certain length
  25.  
  26. The 1982 standards do not allow EDI to be transmitted through Internet
  27. mail, since EDI messages can violate all of these restrictions.  There
  28. are a number of other types of messages and services that have are
  29. supported by other mail standards that have been designed more
  30. recently.  In June of 1992 a new Internet mail standard was approved.
  31. This new standard is called MIME.
  32.  
  33. MIME is an acronym for Multipurpose Internet Mail Extensions.  It
  34. builds on the older standard by standardizing additional fields for
  35. mail message headers that describe new types of content and
  36. organization for messages.
  37.  
  38. MIME allows mail messages to contain:
  39.  
  40.     * Multiple objects in a single message.
  41.  
  42.     * Text having unlimited line length or overall length.
  43.  
  44.     * Character sets other than ASCII.
  45.  
  46.     * Multi-font messages.
  47.  
  48.     * Binary or application specific files.
  49.  
  50.     * Images, Audio, Video and multi-media messages.
  51.  
  52. MIME defines the following new header fields:
  53.  
  54. 1.  A MIME-Version header field, which uses a version number to
  55.     declare that a message conforms to the MIME standard.
  56.  
  57. 2.  A Content-Type header field, which can be used to specify the type
  58.     and subtype of data in the body of a message and to fully specify
  59.     the encoding of such data.
  60.  
  61.     2.a.  A Text Content-Type value, which can be used to represent
  62.           textual information in a number of character sets and
  63.           formatted text description languages in a standardized
  64.           manner.
  65.  
  66.     2.b.  A Multipart Content-Type value, which can be used to combine
  67.           several body parts, possibly of differing types of data,
  68.           into a single message.
  69.  
  70.     2.c.  An Application Content-Type value, which can be used to
  71.           transmit application data or binary data.
  72.  
  73.     2.d.  A Message Content-Type value, for encapsulating a mail
  74.           message.
  75.  
  76.     2.e.  An Image Content-Type value, for transmitting still image
  77.           (picture) data.
  78.  
  79.     2.f.  An Audio Content-Type value, for transmitting audio or voice
  80.           data.
  81.  
  82.     2.g.  A Video Content-Type value, for transmitting video or moving
  83.           image data, possibly with audio as part of the composite
  84.           video data format.
  85.  
  86. 3.  A Content-Transfer-Encoding header field, that specifies how the
  87.     data is encoded to allow it to pass through mail transports having
  88.     data or character set limitations.
  89.  
  90. 4.  Two optional header fields that can be used to further describe
  91.     the data in a message body, the Content-ID and Content-Description
  92.     header fields.
  93.  
  94. MIME is an extensible mechanism.  It is expected that the set of
  95. content-type/subtype pairs and their associated parameters will grow
  96. with time.  Several other MIME fields, such as character set names,
  97. are likely to have new values defined over time.  To ensure that the
  98. set of such values develops in an orderly, and public manner, MIME
  99. defines a registration process which uses the Internet Assigned
  100. Numbers Authority (IANA) as a central registry for such values.
  101.  
  102. To promote interoperability between implementations, the MIME standard
  103. document specifies a minimal subset of the above mechanisms that are
  104. required for an implementation to claim to conform to the MIME
  105. standard.
  106.  
  107.  
  108.  
  109.                         MIME Technical Summary
  110.  
  111. MIME is defined by an Internet standard document called RFC 1341.
  112. This document summarizes the contents of RFC 1341.  Sufficient detail
  113. is presented here to understand the capabilities of MIME.  For
  114. sufficient detail to implement MIME please read RFC 1341.
  115.  
  116. MIME allows messages to contain multiple objects.  When multiple
  117. objects are in a MIME message, they are represented in a form called a
  118. body part.  A body part has a header and a body, so it makes sense to
  119. speak about the body of a body part. Also, body parts can be nested in
  120. bodies that contain one or multiple body parts.
  121.  
  122. The Content-Type values, subtypes, and parameter names defined in the
  123. MIME standard are not case insensitive.  However, many parameter
  124. values are case sensitive.
  125.  
  126. The MIME standard is written to allow MIME to be extended in certain
  127. ways, without having to revise the standard.  MIME specifies sets of
  128. values that are allowed for various fields and parameters.  The
  129. provides a procedure for extending these sets of values by registering
  130. them with an entity called the Internet Assigned Numbers Authority
  131. (IANA).
  132.  
  133.  
  134. The MIME-Version Header Field
  135.  
  136. MIME is designed to be compatible with older Internet mail standards.
  137. In particular, it is compatible with RFC 822.  If a mail reading
  138. program receives a message that is a MIME message then it will likely
  139. perform additional processing for the MIME message that it would not
  140. perform for non-MIME messages.  In order to allow mail reading
  141. programs to recognize MIME messages, MIME messages are required to
  142. contain a MIME-Version header field.  The MIME-Version header field
  143. specifies the version of the MIME standard that the message conforms
  144. to.
  145.  
  146. As of this writing there is only version (1.0) of the MIME standard.
  147. Messages that comply with the standard must include a header field,
  148. with the following verbatim text:
  149.  
  150.         MIME-Version: 1.0
  151.  
  152. The MIME-Version header field is required at the top level of a
  153. message. It is not required for each body part of a multipart entity.
  154. It is required for the embedded headers of a body of type "message" if
  155. and only if the embedded message is claimed to be MIME-compliant.
  156.  
  157.  
  158. The Content-Type Header Field
  159.  
  160. The Content-Type field describes the data contained in the body fully
  161. enough that the mail reader can pick an appropriate mechanism to
  162. present the data to the user, or otherwise deal with the data in an
  163. appropriate manner.
  164.  
  165. The Content-Type header field is used to specify the nature of data in
  166. the body or body part, by giving type and subtype identifiers, and by
  167. providing parameters that may be needed for certain types.  After the
  168. type and subtype names, the remainder of the header field is a set of
  169. parameters, specified in an attribute/value notation.  The set of
  170. meaningful parameters differs for different types.  The order of
  171. parameters is not significant.  Comments are allowed (in accordance
  172. with RFC 822 rules) in structured header fields by placing them in
  173. parentheses.
  174.  
  175. The top-level Content-Type is used to declare the general type of
  176. data, while the subtype specifies a specific format for that type of
  177. data.  Thus, a Content-Type of Image/xyz is enough to tell a mail
  178. reader that the data is an image, even if the mail reader has no
  179. knowledge of the specific image format xyz.  Such information can be
  180. used, to decide whether or not to show a user the raw data from an
  181. unrecognized subtype -- such an action might be reasonable for
  182. unrecognized subtypes of Text, but not for unrecognized subtypes of
  183. Image or Audio.  For this reason, registered subtypes of Audio, Image,
  184. Text, and Video, should not contain embedded information that is
  185. really of a different type.  Such compound types are usually
  186. represented using the Multipart or Application types.
  187.  
  188. Parameters are modifiers of the content-subtype.  Although most
  189. parameters make sense only with certain content-types, others are
  190. "global" in the sense that they might apply to any subtype.  For
  191. example, the Boundary parameter, which is used to indicate how body
  192. parts are separated from each other, makes sense only for the
  193. Multipart content-type.  The Charset parameter might make sense with
  194. several content-types.
  195.  
  196. The MIME standard defines seven content-types.  The authors of the
  197. MIME standard state that the set of seven types is "substantially
  198. complete".  They expect additional supported types to be accommodated
  199. by creating new subtypes of the seven initial top-level types.  The
  200. MIME standard, functioning as a constitution for the MIME community,
  201. states that new standard content types can be defined only by revising
  202. the standard (as opposed to the registration procedure for other types
  203. of extensions).  However, MIME does provide for the use of
  204. non-standard content types.  Non-standard content-types can be used,
  205. but must be given names starting with X-.  Future standard content
  206. type names will not begin with X-.
  207.  
  208. The syntax for the content type header field is
  209.  
  210.     Content-Type := type "/" subtype [";" parameter]...
  211.  
  212. The defined content types are:
  213.  
  214.     Application
  215.         indicates data that does not fit into any of the other
  216.         categories, such as uninterpreted binary data or information
  217.         to be processed by a mail-based application. In addition to
  218.         the following subtypes, it is likely that additional subtypes
  219.         will be defined for applications such as mail-based scheduling
  220.         systems, spreadsheets and EDI.
  221.  
  222.     Application/Octet-Stream
  223.         indicates uninterpreted binary data, which a mail reading
  224.         program may simply offer to write the information into a file.
  225.         Possible parameters for Application/Octet-Stream include:
  226.  
  227.         Name
  228.             a suggested name for the binary data if stored as a file.
  229.  
  230.         Type
  231.             the general type or category of binary data.  This is
  232.             intended for human recipients rather than for automated
  233.             processing.
  234.  
  235.         Conversions
  236.             the operations that performed on the data before putting
  237.             it the body.  Note that the standard defines no conversion
  238.             values.  Any conversion values that do not begin with X-
  239.             must be preceded by a published specification and by
  240.             registration with IANA.
  241.  
  242.         Padding
  243.             the number of bits of padding that were appended to the
  244.             bitstream comprising the actual contents to produce the
  245.             enclosed byte-oriented data.  This is useful for enclosing
  246.             a bitstream in a body when the total number of bits is not
  247.             a multiple of the byte size.
  248.  
  249.     Application/ODA
  250.         indicates a body containing information encoded according to
  251.         the Office Document Architecture (ODA) standards, using the
  252.         ODIF representation format.  For Application/ODA, the
  253.         Content-Type line should also specify an attribute/value pair
  254.         that indicates the document application profile (DAP), using a
  255.         Profile parameter.  Thus an appropriate header field might
  256.         look like this:
  257.  
  258.             Content-Type: application/oda;
  259.                           profile=Q112
  260.  
  261.         Consult the ODA standard for further information.
  262.  
  263.     Application/PostScript
  264.         indicates a body containing a postscript document.
  265.  
  266. Audio
  267.     Indicates audio data.  Audio requires an audio output device (such
  268.     as a speaker or a telephone) to "display" the contents.
  269.  
  270.     Audio/Basic
  271.         The content of the Audio/Basic subtype is audio encoded using
  272.         8-bit ISDN u-law. When this subtype is present, a sample rate
  273.         of 8000 Hz and a single channel is assumed.
  274.  
  275.     Image
  276.         Image data.  Image requires a display device (such as a
  277.         graphical display, a printer, or a FAX machine) to view the
  278.         information.
  279.  
  280.     Image/Jpeg
  281.         indicates an image in JPEG format.
  282.  
  283.     Image/Gif
  284.         indicates an image in GIF format.
  285.  
  286. Message
  287.     indicates an encapsulated message.
  288.  
  289.     Message/Rfc822
  290.         indicates that the body contains an encapsulated message, with
  291.         the syntax of an RFC 822 message.
  292.  
  293.     Message/Partial
  294.         indicates a partial message, allowing fragmented transmission
  295.         of bodies too large to be passed through mail transport
  296.         facilities.  Message/Partial indicates that the body contains
  297.         a fragment of a larger message.
  298.  
  299.         Three parameters are required in a Content-Type field of type
  300.         Message/Partial: The first, Id, is a unique identifier, as
  301.         close to world-unique as possible, used to match the parts
  302.         together.  The second, Number, an integer, is the part number
  303.         indicating where this part fits into the sequence of
  304.         fragments.  The third, Total, another integer, is the total
  305.         number of parts. Total is required on the final part, and
  306.         optional on earlier parts.
  307.  
  308.     Message/External-Body
  309.         indicates that the actual body data are not included, but
  310.         merely referenced.  In this case, the parameters describe a
  311.         mechanism for accessing the external data.
  312.  
  313.         When a body or body part is of type Message/External-Body,
  314.         it consists of a header, a blank line, and the message header
  315.         for the encapsulated message.  If another blank line appears,
  316.         this ends the message header for the encapsulated message.
  317.         However, since the encapsulated message's body is itself
  318.         external, it does not appear in the area that follows.  For
  319.         example, consider this message:
  320.  
  321.             Content-type: message/external-body;
  322.                           access-type=local-file;
  323.                           name=/u/nsb/Me.gif
  324.  
  325.             Content-type: image/gif
  326.  
  327.             THIS IS NOT REALLY THE BODY!
  328.  
  329.         The area at the end, which constitutes a phantom body, is
  330.         ignored for most external-body messages.  However, it may be
  331.         used to contain auxiliary information for a
  332.         "mail-server".
  333.  
  334.         The only parameter of Message/External─Body that is always
  335.         mandatory is Access-Type.  Its other parameters are mandatory
  336.         or optional depending on the value of Access-Type.  The values
  337.         defined for the Access-Type parameter are FTP, ANON-FTP, TFTP,
  338.         AFS, LOCAL-FILE, and MAIL-SERVER.  Except for values beginning
  339.         with X-, other values must be registered with IANA.
  340.  
  341.         The standard also specifies additional parameters that are to
  342.         be used in conjunction with the various access types.
  343.  
  344.         In addition to access-type specific parameters, the standard
  345.         defines the following parameters which are optional for all
  346.         access types:
  347.  
  348.             * The Expiration parameter is used to specify a date after
  349.               which the existence of the external data is not
  350.               guaranteed. 
  351.  
  352.             * The Size parameter is used to specify the size of the
  353.               data.
  354.  
  355. Multipart
  356.  
  357.     indicates data consisting of multiple body parts; each having its
  358.     own data type.  It is possible to tell where each body part begins
  359.     and ends because each body part is preceded by a special string
  360.     called an encapsulation boundary; the last body part is followed
  361.     by a closing boundary.
  362.  
  363.     The boundary strings used are specified by a mandatory parameter
  364.     called Boundary.  The encapsulation boundary is an end of line
  365.     followed by two hyphens followed by the boundary parameter value
  366.     of the Content─Type header field.  The closing boundary is the
  367.     same as the encapsulation boundary with the addition of two
  368.     hyphens at the end of the line.
  369.  
  370.     The encapsulation boundary must not appear inside any of the
  371.     encapsulated parts.  It is crucial that the composing user agent
  372.     be able to choose and specify the unique boundary that will
  373.     separate the body parts.  Encapsulation boundaries may be no
  374.     longer than 70 characters, not counting the blank line and leading
  375.     hyphens.
  376.  
  377.     Thus, a typical multipart Content-Type header field might look
  378.     like:
  379.  
  380.         Content-Type: multipart/mixed; boundary=gc0y0pkb9ex
  381.  
  382.     This indicates a body consisting of several body parts, each
  383.     having a structure syntactically identical to an RFC 822 message,
  384.     except that the header area may be completely empty, and each part
  385.     is preceded by the line
  386.  
  387.         --gc0y0pkb9ex
  388.  
  389.     The closing boundary following the last body part indicates that
  390.     no further body parts will follow.  It is identical to the
  391.     preceding encapsulation boundaries, with the addition of two more
  392.     hyphens at the end of the line:
  393.  
  394.         --gc0y0pkb9ex--
  395.  
  396.     There is room for additional information prior to the first
  397.     encapsulation boundary and following the final boundary.  These
  398.     areas are often blank.  Anything appearing before the first or
  399.     after the last boundary is ignored.
  400.  
  401.     As a simple example, the following multipart message has two
  402.     parts, both plain text, one explicitly typed and one implicitly
  403.     typed:
  404.  
  405.         From: Nathaniel Borenstein <nsb@bellcore.com>
  406.         To: Ned Freed <ned@innosoft.com>
  407.         Subject: Sample message
  408.         MIME-Version: 1.0
  409.         Content-type: multipart/mixed;
  410.                       boundary="simple boundary"
  411.  
  412.         This is the preamble.  It is to be ignored, though it is a
  413.         handy place for mail composers to include an explanatory note
  414.         to non-MIME compliant readers.
  415.  
  416.         --simple boundary
  417.  
  418.         This is implicitly typed plain ASCII text.
  419.         --simple boundary
  420.         Content-type: text/plain; charset=us-ascii
  421.  
  422.         This is explicitly typed plain ASCII text.
  423.         It DOES end with a line break.
  424.  
  425.         --simple boundary--
  426.         This is the epilogue.  It is also to be ignored.
  427.  
  428.     The use of a Content-Type of multipart in a body part within
  429.     another multipart entity is explicitly allowed.  In such cases,
  430.     care must be taken to ensure that each nested multipart entity
  431.     uses a different boundary delimiter.
  432.  
  433.     The use of the multipart Content-Type with only a single body part
  434.     may be useful in certain contexts, and is explicitly permitted.
  435.  
  436.     Multipart/Mixed
  437.         indicates multiple independent body parts to be viewed
  438.         serially.
  439.  
  440.     Multipart/Alternative
  441.         is syntactically identical to Multipart/Mixed.  Each part is
  442.         an "alternative" version of the same information.  Mail
  443.         readers should recognize that the content of the parts are
  444.         interchangeable.  The mail reader should either choose the
  445.         "best" type based on the user's environment and preferences,
  446.         or offer the user the available alternatives.  Generally,
  447.         choosing the best type means displaying only the last part
  448.         that can be displayed.  This may be used, for example, to send
  449.         mail in a fancy text format in such a way that it can easily
  450.         be displayed anywhere:
  451.  
  452.             From:  Nathaniel Borenstein <nsb@bellcore.com>
  453.             To: Ned Freed <ned@innosoft.com>
  454.             Subject: Formatted text mail
  455.             MIME-Version: 1.0
  456.             Content-Type: multipart/alternative;
  457.                           boundary=boundary42
  458.  
  459.  
  460.             --boundary42
  461.             Content-Type: text/plain; charset=us-ascii
  462.  
  463.             ...plain text version of message goes here...
  464.             --boundary42
  465.             Content-Type: text/richtext
  466.  
  467.             ... richtext version of same message goes here ...
  468.             --boundary42
  469.             Content-Type: text/x-whatever
  470.  
  471.             ... fanciest formatted version of same message goes here
  472.             ...
  473.             --boundary42--
  474.  
  475.         In this example, users whose mail system understood the
  476.         text/x-whatever format would see only the fancy version,
  477.         while other users would see only the richtext or plain text
  478.         version, depending on the capabilities of their system.
  479.  
  480.         Some mail reading programs that recognize more than one of the
  481.         formats will offer the user a choice of which format to view.
  482.         This makes sense, for example, if mail includes both a nicely
  483.         formatted image version and an easily edited text version.
  484.         The point is that multiple versions of the same data are not
  485.         automatically shown.  Either the user is shown the last
  486.         recognized version or explicitly given the choice.
  487.  
  488.     Multipart/Parallel
  489.         is syntactically identical to Multipart/Mixed.  However, in a
  490.         parallel body, all of the body parts are intended to be
  491.         presented simultaneously on hardware and software that are
  492.         capable of doing so.  Composing agents should be aware that
  493.         many mail readers will lack this capability and will show the
  494.         parts serially in any event.
  495.  
  496.         Multipart/Parallel will likely be used for multimedia messages
  497.         that combine such message types as text, audio and/or video.
  498.  
  499.     Multipart/Digest
  500.         Indicates that each of the body parts is an RFC 822 mail
  501.         message.  Multipart/Digest is syntactically identical to
  502.         Multipart/Mixed, except that the default Content-Type value
  503.         for a body part is changed from Text/Plain to Message/Rfc822.
  504.  
  505. Text
  506.     The text Content-Type is for sending material that is principally
  507.     textual in form.  It is the default Content-Type.  A Charset
  508.     parameter may be used to indicate the character set of the text.
  509.     The default Content-Type for Internet mail is
  510.         text/plain; Charset=US-ASCII.
  511.  
  512.     The value of the Charset parameter is not case sensitive.
  513.     Allowable values are US-ASCII, ISO-8859-1, ISO-8859-2, ... and
  514.     ISO-8859-9. The default value for Charset is US-ASCII.
  515.  
  516.     Text/Plain
  517.         indicates plain (unformatted) text.  No special software is
  518.         required to get the full meaning of the text, aside from
  519.         support for the indicated character set.  Other subtypes
  520.         should be used for enriched text in forms where application
  521.         software may enhance the appearance of the text, but such
  522.         software must not be required in order to get the general idea
  523.         of the content.  Possible future subtypes include any readable
  524.         word processor format.
  525.  
  526.     Text/Richtext
  527.         indicates a simple portable word processing format that is
  528.         defined by the MIME standard.  It is a very small subset of
  529.         SGML.  Mail readers that implement Richtext may implement only
  530.         a subset of it.
  531.  
  532.         When a mail composing program is given a file in a word
  533.         processing format to send and there is no standardized subtype
  534.         for that format, then the message composing program may
  535.         reformat the file into richtext format which will preserve
  536.         more of the original formatting information than reformatting
  537.         the file to plain ASCII.
  538.  
  539. Video
  540.     indicates that the body contains a time-varying-picture image,
  541.     possibly with color and coordinated sound.  The term Video is
  542.     used very generically and does not refer to any particular
  543.     technology or format.  It is not meant to preclude subtypes
  544.     such as animated drawings encoded compactly.
  545.  
  546.     Video/Mpeg
  547.         indicates video coded according to the MPEG standard.
  548.  
  549. x-TypeName
  550.     This is any type name that begins with X-.  A Content-Type value
  551.     beginning with X- is a private value, to be used by consenting
  552.     mail systems by mutual agreement.  The standard specifies no
  553.     subtypes.
  554.  
  555. No type may be specified without a subtype.
  556.  
  557. The standard allows the use of additional sub-types without having to
  558. change the standard.  However, it is important to insure that
  559. sub-types used by different user communities of MIME do not conflict.
  560. It would be confusing if Content-Type: application/foobar meant two
  561. different things.  The standard specifies two mechanisms for defining
  562. new Content-Type subtypes:
  563.  
  564. 1.  Private values (starting with X-) may be defined between
  565.     cooperating mail composing and reading programs without outside
  566.     registration.  Use of this mechanism requires knowing that the
  567.     reader of the message will not mistake the content type for
  568.     something other than originally intended.
  569.  
  570. 2.  New standard values must be registered with IANA.  Where intended
  571.     for public use, the formats they refer to must also be defined by
  572.     a published specification.
  573.  
  574. Messages that do not have a Content-Type field in their header are
  575. displayed by user agents as if
  576.  
  577.     Content-Type: Text/plain; Charset=US-ASCII
  578.  
  579. had been specified.
  580.  
  581. When a mail reader encounters mail with an unknown Content-Type value,
  582. it will generally treat it as equivalent to application/octet-stream.
  583.  
  584.  
  585. The Content-Transfer-Encoding Header Field
  586.  
  587. Many Content-Types which could usefully be transported via e-mail are
  588. represented, in their "natural" format, as 8-bit character or binary
  589. data.  Such data cannot be transmitted over some transport protocols.
  590. For example, SMTP (Simple Mail Transfer Protocol is an Internet
  591. standard for transporting e-mail defined by a document called RFC 821)
  592. restricts mail messages to 7-bit ASCII data with lines no longer than
  593. 1000 characters.
  594.  
  595. MIME provides two mechanisms for re-encoding such data into a 7-bit
  596. short-line format.  The Content-Transfer-Encoding header field
  597. indicates the mechanism used to perform such an encoding.  The
  598. Content-Transfer-Encoding field indicates the transformation that has
  599. been used to represent the body in an acceptable manner for transport.
  600.  
  601. The possible values for the Content-Transfer-Encoding field are:
  602.         BASE64
  603.         QUOTED-PRINTABLE
  604.         8BIT
  605.         7BIT
  606.         BINARY
  607.         x-EncodingName
  608. These values are not case sensitive.  That is, Base64, BASE64 and
  609. bAsE64 are all equivalent.  An encoding type of 7BIT requires that the
  610. body is already in a 7-bit mail-ready representation.  That is the
  611. default value: Content-Transfer-Encoding: 7BIT is assumed if the
  612. Content-Transfer-Encoding header field is not present.
  613.  
  614. Both BASE64 and the QUOTED-PRINTABLE imply an encoding that consists
  615. of lines no longer than 76 ASCII characters.  In other respects the
  616. two encoding schemes are very different.
  617.  
  618. The encoding scheme implied by QUOTED-PRINTABLE is most appropriate
  619. for data that consists primarily of printable ASCII characters. Using
  620. this encoding method, printable ASCII character are represented as
  621. themselves.  The equals sign (=) serves as an escape character.  Any
  622. character that is not a printable or white space ASCII character is
  623. represented as an equals sign followed by two hexadecimal digits.  An
  624. equals sign in the message is also represented in this way.  Lines
  625. that are longer than 76 characters are cut off after the 75th
  626. character and the line ends with a equals sign.
  627.  
  628. The advantages of using the QUOTED-PRINTABLE encoding for message that
  629. are mostly printable ASCII characters are that few additional
  630. characters are required and the message can be read by human beings
  631. who to not have a MIME aware mail reading program.  As an example,
  632. here is an EDI interchange in QUOTED-PRINTABLE encoding:
  633.  
  634. ISA*00*          *00*          *01*987654321      *12*8005551234     *910=
  635. 607*0111*U*00200*110000777*0*T*>
  636. GS*PO*987654321*8005551234*920501*2032*7721*X*002003
  637. ST*850*000000001
  638. BEG*00*NE*MS1112**920501**CONTRACT#
  639. REF*IT*8128827763
  640. N1*ST*MAVERICK SYSTEMS
  641. N3*3312 NEW HAMPSHIRE STREET
  642. N4*SAN JOSE*CA*94811
  643. PO1*1*25*EA***VC*TP8MM*CB*TAPE8MM
  644. PO1*2*30*EA***VC*TP1/4*CB*TAPE1/4INCH
  645. PO1*3*125*EA***VC*DSK31/2*CB*DISK35
  646. CTT*3
  647. SE*11*000000001
  648. GE*1*7721
  649. IEA*1*110000777
  650.  
  651. Except for the ISA segment having been wrapped onto two lines, the
  652. QUOTED-PRINTABLE encoding of the interchange is identical to its 7BIT
  653. representation.
  654.  
  655. The BASE64 encoding mechanism is well suited for representing binary
  656. files.  It represents any sequence of three bytes as four printable
  657. ASCII characters.  The same interchange as shown above but using the
  658. BASE64 encoding would look like:
  659.  
  660. SVNBKjAwKiAgICAgICAgICAqMDAqICAgICAgICAgICowMSo5ODc2NTQzMjEgICAgICAqMTIq
  661. ODAwNTU1MTIzNCAgICAgKjkxMDYwNyowMTExKlUqMDAyMDAqMTEwMDAwNzc3KjAqVCo+CkdT
  662. KlBPKjk4NzY1NDMyMSo4MDA1NTUxMjM0KjkyMDUwMSoyMDMyKjc3MjEqWCowMDIwMDMKU1Qq
  663. ODUwKjAwMDAwMDAwMQpCRUcqMDAqTkUqTVMxMTEyKio5MjA1MDEqKkNPTlRSQUNUIwpSRUYq
  664. SVQqODEyODgyNzc2MwpOMSpTVCpNQVZFUklDSyBTWVNURU1TCk4zKjMzMTIgTkVXIEhBTVBT
  665. SElSRSBTVFJFRVQKTjQqU0FOIEpPU0UqQ0EqOTQ4MTEKUE8xKjEqMjUqRUEqKipWQypUUDhN
  666. TSpDQipUQVBFOE1NClBPMSoyKjMwKkVBKioqVkMqVFAxLzQqQ0IqVEFQRTEvNElOQ0gKUE8x
  667. KjMqMTI1KkVBKioqVkMqRFNLMzEvMipDQipESVNLMzUKQ1RUKjMKU0UqMTEqMDAwMDAwMDAx
  668. CkdFKjEqNzcyMQpJRUEqMSoxMTAwMDA3NzcK
  669.  
  670. BASE64 bears some resemblance to uuencode in both appearance and
  671. function.  However, uuencode uses characters that may not be processed
  672. properly by an EBCDIC gateway.
  673.  
  674. The values 8bit, 7bit, and binary all imply that no encoding has been
  675. performed. However, they are useful to indicate of the kind of data
  676. contained in the object, and therefore of the kind of encoding that
  677. might need to be performed for transmission in a given transport
  678. system.  7bit means that the data is all represented as short lines of
  679. ASCII data.  8bit means that the lines are short, but there may be
  680. non-ASCII characters.  Binary means that not only may non-ASCII
  681. characters be present, but also that the lines are not necessarily
  682. short enough for SMTP transport.
  683.  
  684. The difference between 8bit and binary is that binary does not require
  685. adherence to any limits on line length.  8bit and binary are intended
  686. for compatibility with future Internet e-mail transport standards and
  687. with gateways to non-Internet environments.  As of this writing there
  688. are no standardized Internet e-mail transports for which it is
  689. legitimate to include unencoded 8-bit or binary data in mail bodies.
  690.  
  691. Note that the five values defined for the Content-Transfer-Encoding
  692. field imply nothing about the Content-Type other than the algorithm by
  693. which it was encoded or the transport system requirements if
  694. unencoded.
  695.  
  696. Some implementations may support additional Content-Transfer-Encoding
  697. values (it is permitted but strongly discouraged by the standard).
  698. Any such additional values must have names that begin with X- to
  699. indicate its non-standard status For example:
  700.  
  701.         Content-Transfer-Encoding: x-my-new-encoding.
  702.  
  703. If a Content-Transfer-Encoding header field appears as part of a
  704. message header, it applies to the entire body of that message.  If a
  705. Content-Transfer-Encoding header field appears as part of a body
  706. part's headers, it applies only to the body of that body part.  If a
  707. message or body part is of type Multipart or Message, the
  708. Content-Transfer-Encoding must be 7bit, 8bit or Binary.
  709.  
  710. The encoding mechanisms defined here explicitly encode all data in
  711. ASCII.  Thus, for example, suppose a message or body part has header
  712. fields such as:
  713.  
  714.         Content-Type: text/plain; charset=ISO-8859-1
  715.         Content-transfer-encoding: base64
  716.  
  717. This should be interpreted to mean that the body is a Base64 ASCII
  718. encoding of data that was originally in ISO-8859-1, and will be in
  719. that character set again after decoding.
  720.  
  721.  
  722. Optional Content-ID Header Field
  723.  
  724. It may be desirable to allow one body to reference another.
  725. Accordingly, bodies may be labeled using the Content-ID header field,
  726. which is syntactically identical to the RFC 822 Message-ID header
  727. field: Content-ID values should be be as unique as possible.
  728.  
  729.  
  730. Optional Content-Description Header Field
  731.  
  732. The ability to associate descriptive information with a body is often
  733. desirable. For example, it may be useful to mark an Image body as
  734. "a picture of the Space Shuttle Endeavor."  Such text may be
  735. placed in the Content-Description header field.
  736.  
  737.  
  738. Summary
  739.  
  740. Using MIME-Version, Content-Type, and Content-Transfer-Encoding header
  741. fields, it is possible to include arbitrary types of data objects in
  742. RFC 822 conformant mail messages.  No restrictions imposed by RFC 821
  743. or RFC 822 are violated. MIME has been designed to avoid problems
  744. caused by additional restrictions imposed by some Internet mail
  745. transport mechanisms. The Multipart and Message content types allow
  746. mixing and hierarchical structuring of objects of different types in a
  747. single message.  Further content types provide a mechanism for tagging
  748. messages or body parts as audio, image, or other kinds of data.  A
  749. parameter syntax allows further specification of data format details,
  750. particularly the specification of alternate character sets.
  751. Additional optional header fields provide mechanisms for certain
  752. extensions deemed desirable by many implementors.  Finally, a number
  753. of useful content types are defined for general use by consenting user
  754. agents, notably Text/Richtext, Message/Partial, and
  755. Message/External-Body.
  756.  
  757. To promote interoperability between user agents, the MIME standard
  758. specifies a minimal subset of MIME features a user agent must support
  759. to be considered MIME conformant.
  760.  
  761.  
  762. A Complex Multipart Example
  763.  
  764. The outline of a complex multipart message follows.  This message has
  765. five parts to be displayed serially: two introductory plain text
  766. parts, an embedded multipart message, a richtext part, and a closing
  767. encapsulated text message in a non-ASCII character set.  The embedded
  768. multipart message has two parts to be displayed in parallel, a picture
  769. and an audio fragment.
  770.  
  771.     MIME-Version: 1.0
  772.     From: Nathaniel Borenstein <nsb@bellcore.com>
  773.     Subject: A multipart example
  774.     Content-Type: multipart/mixed;
  775.                   boundary=unique-boundary-1
  776.  
  777.     This is the preamble area of a multipart message.  Mail readers
  778.     that understand multipart format should ignore this preamble.
  779.     If you are reading this text, you might want to consider changing
  780.     to a mail reader that understands how to properly display
  781.     multipart messages.
  782.     --unique-boundary-1
  783.  
  784.     Some text appears here...
  785.     [Note that the preceding blank line means
  786.     no header fields were given and this is text,
  787.     with charset US ASCII.  It could have been
  788.     done with explicit typing as in the next part.]
  789.  
  790.     --unique-boundary-1
  791.     Content-type: text/plain; charset=US-ASCII
  792.  
  793.     This could have been part of the previous part, but illustrates
  794.     explicit versus implicit typing of body parts.
  795.  
  796.     --unique-boundary-1
  797.     Content-Type: multipart/parallel; boundary=unique-boundary-2
  798.  
  799.     --unique-boundary-2
  800.     Content-Type: audio/basic
  801.     Content-Transfer-Encoding: base64
  802.  
  803.     ... base64-encoded 8000 Hz single-channel
  804.     u-law-format audio data goes here ...
  805.  
  806.     --unique-boundary-2
  807.     Content-Type: image/gif
  808.     Content-Transfer-Encoding: Base64
  809.  
  810.     ... base64-encoded image data goes here...
  811.  
  812.     --unique-boundary-2--
  813.  
  814.     --unique-boundary-1
  815.     Content-type: text/richtext
  816.  
  817.     This is <bold><italic>richtext.</italic></bold><nl><nl>Isn't it
  818.     <bigger><bigger>cool?</bigger></bigger>
  819.  
  820.     --unique-boundary-1
  821.     Content-Type: message/rfc822
  822.  
  823.     From: (name in US-ASCII)
  824.     Subject: (subject in US-ASCII)
  825.     Content-Type: Text/plain; charset=ISO-8859-1
  826.     Content-Transfer-Encoding: Quoted-printable
  827.  
  828.     ... Additional text in ISO-8859-1 goes here ...
  829.  
  830.     --unique-boundary-1--
  831.  
  832.